package gov.fgn.sijyp.general.util;

import java.util.Comparator;

import javax.faces.model.SelectItem;

public class SelectItemComparator implements Comparator<SelectItem>{

	@Override
	public int compare(SelectItem o1, SelectItem o2) {
		
		if(o1.getLabel() == null && o2.getLabel() == null) {
			return 0;
		}
		
		if(o1.getLabel() == null) {
			return -1;
		} else if(o2.getLabel() == null) {
			return 1;
		}
		
		if(o1.getLabel().trim().equals(o2.getLabel().trim())) {
			return 0;
		}
			
		
		if(o1.getLabel().trim().compareTo(o2.getLabel().trim()) < 0) {
			return -1;
		} else {
			return 1;
		}
		
	}

}
